package com.huayun.plugin.fastenerWeightLibrary.service;
import com.huayun.plugin.fastenerWeightLibrary.dao.FastenerWeightLibraryRepository;
import com.huayun.plugin.fastenerWeightLibrary.domain.FastenerWeightLibrary;

import com.huayun.plugin.materialLibrary.domain.MaterialLibrary;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import javax.servlet.http.Part;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;

;

@Service
public class FastenerWeightLibraryService {
    @Autowired
    private final FastenerWeightLibraryRepository fastenerWeightLibraryRepository;
    private final Logger logger = LoggerFactory.getLogger(FastenerWeightLibraryService.class);

    public FastenerWeightLibraryService(FastenerWeightLibraryRepository fastenerWeightLibraryRepository) {
        this.fastenerWeightLibraryRepository = fastenerWeightLibraryRepository;
    }

    public List<FastenerWeightLibrary> queryFastenerWeightLibraryByPartNumber(String PartNumber){
        List<FastenerWeightLibrary> numberContains = fastenerWeightLibraryRepository.findByPartNumberContaining(PartNumber);
        //List<FastenerWeightLibrary> numberContains = fastenerWeightLibraryRepository.findAll();//.stream().filter(weight -> weight.getPartNumber() == "2580C00102G99").collect(Collectors.toList());
        return numberContains;
    }
    public List<FastenerWeightLibrary> getAllFastenerWeightInfoList(){
        List<FastenerWeightLibrary> numberContains = fastenerWeightLibraryRepository.findAll();
        return numberContains;
    }

}
